package service;

import lombok.extern.slf4j.Slf4j;
import mapper.ModusTableMapper;
import model.ModusTable;
import utils.MybatisUtils;

import java.util.List;

/**
 * 查询所有通道 设备
 *
 * @author 修唯xiuwei
 * @Email 524710549@qq.com
 **/
@Slf4j
public class ModusTableService {

	private static class LazyHolder {
		private static final ModusTableService INSTANCE = new ModusTableService();
	}

	private ModusTableService() {
	}

	public static final ModusTableService getInstance() {
		return LazyHolder.INSTANCE;
	}


	private ModusTableMapper modusTableMapper = MybatisUtils.getSqlSession().getMapper(ModusTableMapper.class);


	public List<ModusTable> getAllModusTable(String ipIdentity) {
		if (modusTableMapper.isTableExit(ipIdentity) < 1) {
			return null;
		}
		return modusTableMapper.getAllModusTable(ipIdentity);
	}

	public void updateModusValue(String ipIdentity, int id, String value, String time) {
		log.info("向modustable_" + ipIdentity + "的ID=" + id + "存入数据" + value + ",时间:" + time);
		modusTableMapper.updateModusValue(ipIdentity, id, value, time);
	}


}
